package iscript.uiFramework.util 
{
	import flash.display.Graphics;
	import flash.geom.Rectangle;
	import iscript.coreFramework.math.Point2D;
	import iscript.coreFramework.math.Vector2D;

	
	public class LineSegment 
	{
		
		public function LineSegment() 
		{
			
		}
		
		public var thickness:Number = 1;		
		public var lineColor:uint = 0x000000;		
		public var lineAlpha:Number = 1;
		
		public var fillColor:uint = 0x000000;
		public var fillAlpha:Number = 0.5;
		
		
		//(thickness:Number=null, color:uint=0, alpha:
		
		public function drawVector2D(graphics:Graphics, v:Vector2D):void {
			var p:Vector.<Point2D> = new Vector.<Point2D>()
			p.push(v.P0)
			p.push(v.P1);
			drawVectorPoint2D(graphics,p);
			}
		
		public function drawPoint2D(graphics:Graphics, pos:Point2D):void {
			     graphics.lineStyle(thickness,lineColor,lineAlpha);	
				 graphics.beginFill(fillColor,fillAlpha);
				 graphics.moveTo(pos[0].x, pos[0].y); 
				 graphics.lineTo(pos[1].x, pos[1].y);
				 graphics.lineTo(pos[0].x, pos[0].y); 
				 graphics.endFill();
			}
		
		public function drawVectorPoint2D(graphics:Graphics, pos:Vector.<Point2D>):void {
			     graphics.lineStyle(thickness,lineColor,lineAlpha);	
				 graphics.beginFill(fillColor,fillAlpha);
				 for (var i:int = 0; i <pos.length 	; i++) 
				 {
					 if (i == 0) {
						 graphics.moveTo(pos[i].x, pos[i].y); 
						 }else {
							 
						graphics.lineTo(pos[i].x, pos[i].y);
					}
				 }
				  graphics.lineTo(pos[0].x, pos[0].y); 
				 graphics.endFill();
			}
		
		public function drawRectangle(graphics:Graphics, rect:Rectangle):void {
			     graphics.lineStyle(thickness,lineColor,lineAlpha);	
				 graphics.beginFill(fillColor,fillAlpha);
				 graphics.drawRect(rect.x, rect.y, rect.width, rect.height);
				 graphics.endFill();
			}
	}

}